/** 
     * @param {object} geometry  [evt.feature.getGeometry()]
     * @param {service} {name,layerId}
     */
class Query {
    /* 配置画笔 */
    static queryByGeom({
        geometry,
        service,
        pageIndex,
        recordNumber,
        success
    }) {
        /* 1、查询结构 */
        //初始化查询结构对象，设置查询结构包含几何信息
        var queryStruct = new Zondy.Service.QueryFeatureStruct();
        //是否包含几何图形信息
        queryStruct.IncludeGeometry = true;
        //是否包含属性信息
        queryStruct.IncludeAttribute = true;
        //是否包含图形显示参数
        queryStruct.IncludeWebGraphic = false;
        //2、创建一个用于查询的区
        var geomObj = new Zondy.Object.Polygon();
        geomObj.setByOL(geometry);
        /* 3、确定查询的规则 */
        //指定查询规则
        var rule = new Zondy.Service.QueryFeatureRule({
            //是否将要素的可见性计算在内
            EnableDisplayCondition: false,
            //是否完全包含
            MustInside: false,
            //是否仅比较要素的外包矩形
            CompareRectOnly: false,
            //是否相交
            Intersect: true
        });
        //4、实例化查询参数对象
        var queryParam = new Zondy.Service.QueryParameter({
            geometry: geomObj,
            resultFormat: "json",
            struct: queryStruct,
            rule: rule
        });
         //设置查询分页号
         queryParam.pageIndex = pageIndex;
         //设置查询要素数目
         queryParam.recordNumber = recordNumber;
        //5、实例化地图文档查询服务对象
        var queryService = new Zondy.Service.QueryDocFeature(queryParam, service.name, service.layerId, {

        });
        //执行查询操作，querySuccess为查询回调函数
        queryService.query(success);
    }
    static queryByLayer({
        service,
        success
    }) {
        /* 1、查询结构 */
        //初始化查询结构对象，设置查询结构包含几何信息
        var queryStruct = new Zondy.Service.QueryFeatureStruct();
        //是否包含几何图形信息
        queryStruct.IncludeGeometry = true;
        //是否包含属性信息
        queryStruct.IncludeAttribute = true;
        //是否包含图形显示参数
        queryStruct.IncludeWebGraphic = false;
        //指定查询规则
        /* 2、rule */
        var rule = new Zondy.Service.QueryFeatureRule({
            //是否将要素的可见性计算在内
            EnableDisplayCondition: false,
            //是否完全包含
            MustInside: false,
            //是否仅比较要素的外包矩形
            CompareRectOnly: false,
            //是否相交
            Intersect: true
        });
        /* 3、查询参数 */
        var queryParam = new Zondy.Service.QueryParameter({
            resultFormat: "json",
            struct: queryStruct,
            rule: rule
        });
        queryParam.recordNumber = 10000;
        //实例化地图文档查询服务对象
        var queryService = new Zondy.Service.QueryDocFeature(queryParam, service.name, service.layerId, {

        });
        //执行查询操作，querySuccess为查询回调函数
        queryService.query(success);
    }
    static queryByAttr({
        service,
        where,
        success
    }) {
        var queryStruct = new Zondy.Service.QueryFeatureStruct();
        //是否包含几何图形信息
        queryStruct.IncludeGeometry = true;
        //是否包含属性信息
        queryStruct.IncludeAttribute = true;
        //是否包含图形显示参数
        queryStruct.IncludeWebGraphic = false;
        //实例化查询参数对象
        var queryParam = new Zondy.Service.QueryParameter({
            resultFormat: "json",
            struct: queryStruct
        });
        //设置查询分页号
        queryParam.pageIndex = 0;
        //设置查询要素数目
        queryParam.recordNumber = 20;
        /* select * from p1 where name like %张三% */
        // queryParam.where = `name like '%张三%'`;
        queryParam.where = where
        var queryService = new Zondy.Service.QueryDocFeature(queryParam, service.name, service.layerId, {

        });
        //执行查询操作，querySuccess为查询回调函数
        queryService.query(success);
    }
    /* fid可以单个值,也可以传递数组 */
    static queryByFid({
        service,
        fid,
        success
    }) {
        var queryStruct = new Zondy.Service.QueryFeatureStruct();
        //是否包含几何图形信息
        queryStruct.IncludeGeometry = true;
        //是否包含属性信息
        queryStruct.IncludeAttribute = true;
        //是否包含图形显示参数
        queryStruct.IncludeWebGraphic = false;
        //2、实例化查询参数对象
        var queryParam = new Zondy.Service.QueryParameter({
            objectIds: fid,
            resultFormat: "json",
            struct: queryStruct
        });
        /* 3、调用查询服务 */
        //实例化地图文档查询服务对象
        var queryService = new Zondy.Service.QueryDocFeature(queryParam, service.name, service.layerId, {

        });
        //执行查询操作，querySuccess为查询回调函数
        queryService.query(success);
    }
    static queryByUrl({
      service,
      url,
      success
    }){
      // 线图层查询,查OID
      var queryStruct = new Zondy.Service.QueryFeatureStruct();
      //是否包含几何图形信息
      queryStruct.IncludeGeometry = true;
      //是否包含属性信息
      queryStruct.IncludeAttribute = true;
      //是否包含图形显示参数
      queryStruct.IncludeWebGraphic = false;
      var rule = new Zondy.Service.QueryFeatureRule({
        //是否将要素的可见性计算在内
        EnableDisplayCondition: false,
        //是否完全包含
        MustInside: false,
        //是否仅比较要素的外包矩形
        CompareRectOnly: false,
        //是否相交
        Intersect: true,
      });
      // 实例化查询参数对象
      var queryParam = new Zondy.Service.QueryByLayerParameter(
        url,
        {
          resultFormat: "json",
          struct: queryStruct,
          rule: rule,
        }
      );
      //实例化地图文档查询服务对象
      var queryService = new Zondy.Service.QueryLayerFeature(queryParam, {
        ip: "localhost",
        port: "6163", //访问IGServer的端口号，.net版为6163，Java版为8089
      });
      //执行查询操作，success为查询回调函数
      queryService.query(success);
      
    }
}
export { Query }